/**
 * Copyright (C) 2008 Stefan Maassen
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package de.indisopht.guice.groovy;

import com.google.inject.Provider;


/**
 * Integrates Guice with Groovy. Requires a constant or collection bound to
 * {@link de.indisopht.guice.groovy.GroovyClasspath}.
 * 
 * @deprecated scheduled for removal with release 0.4.0
 * 
 * @author Stefan Maassen
 */
@Deprecated
public final class GroovyIntegration<T> {

    private GroovyIntegration() {
    }
    
    /**
     * Creates a provider for MyClass using the given name pointing to a file or
     * by parsing the given string as a class. <br>
     * <br>Example usage:<br>
     * 
     * <pre>
     * &lt;b&gt;Binding a groovy class to a java class&lt;/b&gt;
     * <code>
     * binder.bindConstant().annotatedWith(GroovyClasspath.class).to(System.getProperty(&quot;groovy.classpath&quot;));
     * bind(MyClass.class).to(fromGroovy(MyClass.class, &quot;com.mypackage....&quot;));
     * </code>
     * &lt;b&gt;Binding grovvy code inside a string to a java class&lt;/b&gt;
     * <code>
     * bind(MyClass.class).to(fromGroovy(MyClass.class, &quot;import a.b.c; class B extends MyClass { }&quot;));
     * </code>
     * &lt;b&gt;Binding a grovvy script inside a string&lt;/b&gt;
     * <code>
     * binder.bind(Script.class).toProvider(GroovyIntegration.fromGroovy(Script.class, &quot;println('groovy hello'); 'groovy'&quot;));
     * </code>
     * &lt;b&gt;Binding a grovvy script from a file&lt;/b&gt;
     * <code>
     * binder.bindConstant().annotatedWith(GroovyClasspath.class).to(URLClassLoader.getSystemResource(&quot;TestScript.groovy&quot;).getPath());
     * binder.bind(Script.class).toProvider(GroovyIntegration.fromGroovy(Script.class, &quot;TestScript&quot;));
     * </code>
     * &lt;b&gt;Binding security permissions to scripts from .policy files&lt;/b&gt;
     * <code>
     * binder.bindConstant().annotatedWith(GroovyCodeBase.class).to("/secure/codeBase"));
     * </code>
     * &lt;b&gt;Set resolving behaviour of GroovyClassloader&lt;/b&gt;
     * <code>
     * binder.bindConstant().annotatedWith(GroovyResolve.class).to(Boolean.TRUE);
     * </code>
     * </pre>
     * <pre>
     * &lt;b&gt;NOTE: MyClass must be known at runtime, when binding to Groovy.&lt;/b&gt;
     * </pre>
     * 
     * @deprecated will be removed within next release
     * 
     */
    @Deprecated
    public static <T> Provider<T> fromGroovy(Class<T> type, String somethingGroovy) {
    	GroovyProvider<T> result=new GroovyProvider<T>(somethingGroovy){};
    	result.setBindingType(type);
        return result;
    }
}